<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="keywords" content="">
    <meta name="author" content="">
    <meta name="robots" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>申请详情</title>
    <link href="/css/nice-select.css" rel="stylesheet">
    <link href="/css/jquery.dataTables.min.css" rel="stylesheet">
    <link href="/css/bootstrap-datepicker.min.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
    <div class="d-flex align-items-center mb-4">
        <h4 class="fs-20 font-w600 mb-0 me-auto">申请详情</h4>
        <div>
            <a href="javascript:void(0);" class="btn btn-secondary btn-sm me-3"> <i class="fas fa-envelope"></i></a>
            <a href="javascript:void(0);" class="btn btn-secondary btn-sm me-3"><i class="fas fa-phone-alt"></i></a>
            <a href="javascript:void(0);" class="btn btn-primary btn-sm"><i class="fas fa-info"></i></a>
        </div>
    </div>
    <div class="row">
        <div class="col-xl-12">
            <div class="card">
                <div class="card-header border-0 flex-wrap align-items-start">
                    <div class="col-md-8">
                        <div class="user d-sm-flex d-block pe-md-5 pe-0">
                            <!-- 用户头像 -->
                            <img th:if="${apply.seeker.info.avatarHash}" th:src="@{'/picture/' + ${apply.seeker.info.avatarHash}}" alt="头像">
                            <img th:unless="${apply.seeker.info.avatarHash}" src="/picture/user.jpg" alt="默认头像">
                            <div class="ms-sm-3 ms-0 me-md-5 md-0">
                                <!-- 用户真实姓名 -->
                                <h5 class="mb-1 font-w600">
                                    <a href="javascript:void(0);" th:text="${apply.seeker.info.realName}">Andrew Jonson</a>
                                </h5>
                                <div class="listline-wrapper mb-2">
                                    <!-- 邮箱 -->
                                    <span class="item"><i class="far fa-envelope"></i>
                                        <span th:text="${apply.seeker.info.email}">example@gmail.com</span>
                                    </span>
                                    <!-- 申请的职位 -->
                                    <span class="item"><i class="far fa-id-badge"></i>
                                        <span th:text="${apply.job.title}">职位名称</span>
                                    </span>
                                    <!-- 地区信息 -->
                                    <span class="item"><i class="fas fa-map-marker-alt"></i>
                                        <span th:if="${apply.seeker.info.region}" th:text="${apply.seeker.info.region.name}">地区</span>
                                        <span th:unless="${apply.seeker.info.region}">未知地区</span>
                                    </span>
                                </div>
                                <!-- 用户描述 -->
                                <p th:text="${apply.seeker.info.description}">用户描述信息</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4 col-12 text-end">
                        <a href="javascript:void(0);" class="btn btn-sm btn-primary me-2">Ask</a>
                        <a href="javascript:void(0);" class="btn btn-sm btn-info">Hire</a>
                        <div class="mt-3">
                            <!-- 申请状态 -->
                            <h6 class="text-start">申请状态
                                <span class="float-end">
                                    <span th:switch="${apply.status}">
                                        <span th:case="0">待定</span>
                                        <span th:case="1">通过</span>
                                        <span th:case="2">拒绝</span>
                                    </span>
                                </span>
                            </h6>
                            <!-- 进度条根据状态变化 -->
                            <div class="progress">
                                <div th:switch="${apply.status}"
                                     th:classappend="${apply.status} == 0 ? 'bg-warning' :
                                                     (${apply.status} == 1 ? 'bg-success' : 'bg-danger')"
                                     class="progress-bar progress-animated"
                                     th:style="'width:' + (${apply.status} == 0 ? 33 : 100) + '%; height:6px;'"
                                     role="progressbar">
                                    <span class="sr-only">申请状态</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card-body pt-0">
                    <h4 class="fs-20">详细信息</h4>
                    <div class="row">
                        <div class="col-xl-6 col-md-6">
                            <!-- 左侧信息列 -->
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">真实姓名：</span>
                                <span class="font-w400" th:text="${apply.seeker.info.realName}">Andrew Jonson</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">申请职位：</span>
                                <span class="font-w400" th:text="${apply.job.title}">职位名称</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">职位类型：</span>
                                <span class="font-w400" th:text="${apply.job.jobType}">职位类型</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">薪资范围：</span>
                                <span class="font-w400" th:text="${apply.job.salaryRange}">薪资范围</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">申请时间：</span>
                                <span class="font-w400" th:text="${#temporals.format(apply.applyTime, 'yyyy-MM-dd HH:mm:ss')}">2023-01-01 10:00:00</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">职位状态：</span>
                                <span class="font-w400" th:text="${apply.job.status == 1 ? '开放中' : '已关闭'}">开放中</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">性别：</span>
                                <span class="font-w400" th:text="${apply.seeker.info.gender}">男/女</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">学历要求：</span>
                                <span class="font-w400" th:text="${apply.job.education}">学历要求</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">反馈信息：</span>
                                <span class="font-w400" th:text="${apply.feedback} ?: '暂无反馈'">反馈信息</span>
                            </p>
                        </div>
                        <div class="col-xl-6 col-md-6">
                            <!-- 右侧信息列 -->
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">联系电话：</span>
                                <span class="font-w400" th:text="${apply.seeker.info.phone}">1234598765</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">身份证号：</span>
                                <span class="font-w400" th:text="${apply.seeker.info.idCard}">身份证号</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">出生日期：</span>
                                <span class="font-w400" th:text="${#temporals.format(apply.seeker.info.birthday, 'yyyy-MM-dd')}">1990-01-01</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">工作地点：</span>
                                <span class="font-w400" th:text="${apply.job.location}">工作地点</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">职位描述：</span>
                                <span class="font-w400" th:text="${apply.job.description}">职位描述信息</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">详细地址：</span>
                                <span class="font-w400" th:text="${apply.seeker.info.addressDetail}">详细地址</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">创建时间：</span>
                                <span class="font-w400" th:text="${#temporals.format(apply.seeker.info.createTime, 'yyyy-MM-dd HH:mm:ss')}">2023-01-01 10:00:00</span>
                            </p>
                            <p class="font-w600 mb-2 d-flex">
                                <span class="custom-label-2">更新时间：</span>
                                <span class="font-w400" th:text="${#temporals.format(apply.seeker.info.updateTime, 'yyyy-MM-dd HH:mm:ss')}">2023-01-01 10:00:00</span>
                            </p>
                        </div>
                    </div>
                </div>
                <div class="card-footer d-flex flex-wrap justify-content-between">
                    <div class="mb-md-2 mb-3">
                        <span class="d-block mb-1">
                            <i class="fas fa-circle me-2"></i>申请职位
                            <strong th:text="${apply.job.title}">职位名称</strong>
                        </span>
                        <span>
                            <i class="fas fa-circle me-2"></i>申请时间
                            <strong th:text="${#temporals.format(apply.applyTime, 'yyyy-MM-dd HH:mm:ss')}">2023-01-01 10:00:00</strong>
                        </span>
                    </div>
                    <div>
                        <!-- 修改下载简历按钮：添加求职者ID属性 -->
                        <a id="downloadResumeBtn"
                           th:if="${apply.seeker.resumeHash}"
                           th:attr="data-seeker-id=${apply.seeker.id}"
                           class="btn btn-primary btn-md me-2 mb-2">
                            <i class="fas fa-download me-2"></i>下载简历
                        </a>
                        <a th:unless="${apply.seeker.resumeHash}"
                           class="btn btn-primary btn-md me-2 mb-2 disabled">
                            <i class="fas fa-download me-2"></i>简历不可用
                        </a>

                        <a href="javascript:void(0);" class="btn btn-warning btn-md me-2 mb-2">
                            <i class="fas fa-share-alt me-2"></i>分享资料
                        </a>

                        <!-- 修改联系求职者按钮：添加求职者ID属性 -->
                        <a id="contactSeekerBtn"
                           th:attr="data-seeker-id=${apply.seeker.id}"
                           class="btn btn-info btn-md me-2 mb-2">
                            <i class="fas fa-phone-alt me-2"></i>联系求职者
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/js/global.min.js"></script>
<script src="/js/Chart.bundle.min.js"></script>
<script src="/js/jquery.nice-select.min.js"></script>
<script src="/js/jquery.dataTables.min.js"></script>
<script src="/js/datatables.init.js"></script>
<script src="/js/bootstrap-datepicker.min.js"></script>
<script src="/js/custom.min.js"></script>
<script src="/js/dlabnav-init.js"></script>
<script src="/js/demo.js"></script>
<script>
    $(document).ready(function() {
        // 1. 联系求职者功能
        $('#contactSeekerBtn').on('click', function() {
            const seekerId = $(this).data('seeker-id');  // 获取求职者ID
            const currentUserId = [[${session.account?.id}]];  // 当前登录用户ID

            // 跳转到聊天页面（需确保后端有对应接口）
            window.location.href = '/user/chat?senderId=' + currentUserId + '&receiverId=' + seekerId;
        });

        // 2. 下载简历功能
        $('#downloadResumeBtn').on('click', function(e) {
            e.preventDefault();  // 阻止默认链接行为
            const seekerId = $(this).data('seeker-id');  // 获取求职者ID

            // 调用后端下载接口
            const downloadUrl = '/api/account/downloadResume/' + seekerId;

            // 创建隐藏的iframe触发下载
            const iframe = document.createElement('iframe');
            iframe.style.display = 'none';
            iframe.src = downloadUrl;
            document.body.appendChild(iframe);
        });

        // 3. 简历不可用提示
        $('.btn.disabled').on('click', function(e) {
            e.preventDefault();
            alert('该求职者尚未上传简历');
        });
    });
</script>
</body>
</html>